/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TimeRecording.reporting;

import TimeRecording.business.HolidayCalculations;
import TimeRecording.enums.PartOfDay;
import TimeRecording.tables.Employee;
import java.awt.Image;
import java.util.Date;

/**
 *
 * @author david
 */
public class HolidayIconProvider extends CalendarIconProvider {

    private static boolean imagesLoaded = false;
    
    protected static Image holidayAmIcon;
    protected static Image holidayPmIcon;
    protected static Image holidayIcon;

    public HolidayIconProvider() {

        super();

        if (!imagesLoaded) {
            holidayAmIcon = loadImage("HolidayAm");
            holidayPmIcon = loadImage("HolidayPm");
            holidayIcon = loadImage("HolidayAllDay");
        }
    }

    public Image getIcon(Employee employee, Date date) {

        PartOfDay holidayDay = HolidayCalculations.isOnHoliday(
                employee, date, true);

        if (holidayDay == null) {
            return presentIcon;
        } else {
            switch (holidayDay) {
                case ALL_DAY:
                    return holidayIcon;
                case AM:
                    return holidayAmIcon;
                case PM:
                    return holidayPmIcon;
                default:
                    return presentIcon;
            }
        }
    }
}
